#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <ctime>

#include "WeightSensor.h"

WeightSensor* weightSensorConstruct()
{
	WeightSensor *weightSensor;
	weightSensor = (WeightSensor*) malloc(sizeof(WeightSensor));
	weightSensor->weight = 0;
	weightSensor->isUserSet = no;
	return weightSensor;
}

void weightSensorDeconstruct(WeightSensor *weightSensor)
{
	free(weightSensor);
}

void weightSensorSetWeight(WeightSensor *weightSensor, int weight)
{
	weightSensor->weight = weight;
	weightSensor->isUserSet = yes;
}

void measureWeight(WeightSensor *weightSensor)
{
	if (weightSensor->isUserSet == no)
	{
		// This is where you would communicate with the hardware
		srand(time(NULL));
		weightSensor->weight = rand() % 2000 + 1;
	}
}